package Text_30;

import java.util.Arrays;
import java.util.Comparator;

public class Code {

	public static void main(String[] args) {
		GireFriend gf1 = new GireFriend("king",12,160);
        GireFriend gf2 = new GireFriend("Tom",18,170);
        GireFriend gf3 = new GireFriend("ki",16,180);
        GireFriend[] arr = {gf1,gf2,gf3};

        Arrays.sort(arr, new Comparator<GireFriend>() {

            @Override
            public int compare(GireFriend o1, GireFriend o2) {
                double temp = o1.getAge()-o2.getAge();
                temp = temp==0? o1.getHigh()-o2.getHigh():temp;
                temp = temp==0? o1.getName().compareTo(o2.getName()):temp;
                if(temp>0){
                    return 1;
                }else if(temp<0){
                    return -1;
                }else{
                    return 0;
                }
            }
        });
        System.out.println(Arrays.toString(arr));

	}

}
